/**
 * 特殊的对象格式化url 参数形式 将数组转换成 
 *  x[]=123&x[]=456
 * @param {*} param 
 * @param {*} key 
 * @param {*} encode 
 */

export function stringify(param, key, encode) {
    if (param == null) return "";
    var paramStr = "";
    var t = typeof param;
    if (t == "string" || t == "number" || t == "boolean") {
        paramStr +=
            "&" +
            key +
            "=" +
            (encode == null || encode ? encodeURIComponent(param) : param);
    } else {
        for (var i in param) {
            var k =
                key == null
                    ? i
                    : key + (param instanceof Array ? "[" + "]" : "." + i);
            paramStr += stringify(param[i], k, encode);
        }
    }
    return paramStr;
}